import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import "@/assets/css/normalize.css"
import "@/assets/css/default.css"
// 全局样式
import "@/assets/css/globalStyle.css"

// axios
import api from '@/api'
Vue.prototype.$api = api

//按需引入 vantUI

import {
    Icon
} from 'vant';
import {
    Swipe,
    SwipeItem
} from 'vant';

Vue.use(Swipe).use(SwipeItem).use(Icon);



// 全局引入 swiper
import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
Vue.use(VueAwesomeSwiper, /* { default global options } */ )


// 导入vue-i18n 翻译
import VueI18n from "vue-i18n";
// 插件形式挂载
Vue.use(VueI18n);



const i18n = new VueI18n({
    locale: 'zh-CN', // 语言标识
    //this.$i18n.locale // 通过切换locale的值来实现语言切换
    messages: {
        'zh-CN': require('./common/lang/zh'), // 中文语言包
        'en-US': require('./common/lang/en') // 英文语言包
    }
})

router.beforeEach((to, from, next) => {
    let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
    if (flag) {
        console.log('守卫说是移动端')
        store.commit('isMobile')

    } else {
        console.log('守卫说是pc端')
        store.commit('isPc')
    }
    next();
})

Vue.config.productionTip = false
Vue.use(ElementUI);
new Vue({
    router,
    store,
    i18n,
    render: h => h(App)
}).$mount('#app')